<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>AI预测 - LabEnergyInsight</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
    <!-- 使用本地Chart.js资源 -->
    <script src="assets/js/chart.umd.min.js"></script>
</head>
<body class="bg-gray-50">
    <!-- Header -->
    <div class="bg-white p-4 shadow-sm">
        <div class="flex justify-between items-center">
            <h1 class="text-xl font-semibold">AI预测中心</h1>
            <div class="flex items-center space-x-2">
                <button class="p-2">
                    <i class="fas fa-ellipsis-v text-gray-500"></i>
                </button>
            </div>
        </div>
    </div>

    <!-- Main Content -->
    <div class="p-4 space-y-4">
        <!-- Model Selection -->
        <div class="bg-white rounded-xl p-4 shadow-sm">
            <div class="flex justify-between items-center mb-4">
                <h2 class="font-semibold">预测模型</h2>
                <select class="text-sm border rounded-lg px-2 py-1">
                    <option>LSTM模型</option>
                    <option>XGBoost模型</option>
                    <option>ARIMA模型</option>
                </select>
            </div>
            <div class="flex space-x-2">
                <button class="flex-1 bg-blue-500 text-white py-2 rounded-lg text-sm">
                    <i class="fas fa-play mr-1"></i> 开始预测
                </button>
                <button class="flex-1 border border-blue-500 text-blue-500 py-2 rounded-lg text-sm">
                    <i class="fas fa-download mr-1"></i> 导出结果
                </button>
            </div>
        </div>

        <!-- Prediction Chart -->
        <div class="bg-white rounded-xl p-4 shadow-sm">
            <div class="flex justify-between items-center mb-4">
                <h2 class="font-semibold">未来7天能耗预测</h2>
                <div class="flex space-x-2">
                    <button class="text-xs px-2 py-1 bg-blue-50 text-blue-500 rounded">7天</button>
                    <button class="text-xs px-2 py-1 text-gray-500 rounded">30天</button>
                </div>
            </div>
            <canvas id="predictionChart" height="200"></canvas>
            <div class="mt-4 text-sm text-gray-500">
                <p>预测准确率：95.8%</p>
                <p>置信区间：±5%</p>
            </div>
        </div>

        <!-- Anomaly Detection -->
        <div class="bg-white rounded-xl p-4 shadow-sm">
            <h2 class="font-semibold mb-4">异常检测</h2>
            <div class="space-y-3">
                <div class="flex items-center justify-between p-3 bg-red-50 rounded-lg">
                    <div class="flex items-center space-x-3">
                        <div class="bg-red-100 p-2 rounded-lg">
                            <i class="fas fa-exclamation-triangle text-red-500"></i>
                        </div>
                        <div>
                            <p class="font-medium">能耗突增</p>
                            <p class="text-xs text-red-500">2024-03-15 14:30</p>
                        </div>
                    </div>
                    <div class="text-red-500">
                        <i class="fas fa-chevron-right"></i>
                    </div>
                </div>
                <div class="flex items-center justify-between p-3 bg-yellow-50 rounded-lg">
                    <div class="flex items-center space-x-3">
                        <div class="bg-yellow-100 p-2 rounded-lg">
                            <i class="fas fa-exclamation-circle text-yellow-500"></i>
                        </div>
                        <div>
                            <p class="font-medium">设备异常</p>
                            <p class="text-xs text-yellow-500">2024-03-15 10:15</p>
                        </div>
                    </div>
                    <div class="text-yellow-500">
                        <i class="fas fa-chevron-right"></i>
                    </div>
                </div>
            </div>
        </div>

        <!-- Model Performance -->
        <div class="bg-white rounded-xl p-4 shadow-sm">
            <h2 class="font-semibold mb-4">模型性能</h2>
            <div class="grid grid-cols-2 gap-4">
                <div class="bg-gray-50 p-3 rounded-lg">
                    <p class="text-sm text-gray-500">RMSE</p>
                    <p class="text-xl font-bold mt-1">0.023</p>
                </div>
                <div class="bg-gray-50 p-3 rounded-lg">
                    <p class="text-sm text-gray-500">MAE</p>
                    <p class="text-xl font-bold mt-1">0.018</p>
                </div>
                <div class="bg-gray-50 p-3 rounded-lg">
                    <p class="text-sm text-gray-500">R² Score</p>
                    <p class="text-xl font-bold mt-1">0.958</p>
                </div>
                <div class="bg-gray-50 p-3 rounded-lg">
                    <p class="text-sm text-gray-500">训练时间</p>
                    <p class="text-xl font-bold mt-1">2.5h</p>
                </div>
            </div>
        </div>
    </div>

    <script>
        // Prediction Chart
        const ctx = document.getElementById('predictionChart').getContext('2d');
        new Chart(ctx, {
            type: 'line',
            data: {
                labels: ['3/15', '3/16', '3/17', '3/18', '3/19', '3/20', '3/21'],
                datasets: [{
                    label: '实际值',
                    data: [2500, 2600, 2400, 2700, 2600, 2800, 2900],
                    borderColor: '#3B82F6',
                    backgroundColor: 'rgba(59, 130, 246, 0.1)',
                    tension: 0.4,
                    fill: true
                }, {
                    label: '预测值',
                    data: [null, null, null, 2650, 2750, 2850, 2950],
                    borderColor: '#10B981',
                    borderDash: [5, 5],
                    tension: 0.4
                }]
            },
            options: {
                responsive: true,
                plugins: {
                    legend: {
                        display: true,
                        position: 'top'
                    }
                },
                scales: {
                    y: {
                        beginAtZero: false,
                        grid: {
                            display: true,
                            color: 'rgba(0, 0, 0, 0.05)'
                        }
                    },
                    x: {
                        grid: {
                            display: false
                        }
                    }
                }
            }
        });
    </script>
</body>
</html> 